<!doctype html>
<html>

<head>
	<meta charset="utf-8">
	<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
	<meta name="format-detection" content="telephone=no" />
	<title>首页</title>
	<link rel="stylesheet" type="text/css" href="../c/aui.css" />
	<link rel="stylesheet" type="text/css" href="../c/fang.css" />
</head>

<body>
	<div class="f-slide"></div>
	<div id="sx-view"></div>
	<script id="sx-list" type="text/x-dot-template">
	{{ for(var i=0; i < it.length; i++) { }}
	<div class="f-list">
		<div class="h2"  tapmode onclick="_url({url:'fang_list',title:'{{= it[i].title}}列表',type:{{= it[i].id}},bounces:{{? it[i].id !=0}}true{{??}}false{{?}}})">
			<div class="l">
				<em></em><span>{{= it[i].title}}</span>
			</div>
			<div class="r">更多<i class="aui-iconfont aui-icon-right"></i></div>
		</div>
		<div class="f-ul">
			{{ for(var i_s=0; i_s < it[i].list.length; i_s++) { }}
			<div class="li" tapmode onclick="_url({aid:{{= it[i].list[i_s].id }}},'fang_view_win')">
				<div class="img" style="height:{{= (li_w/3)+50 }}px">
					<img suxiangw-src="{{= _img(it[i].list[i_s].img,(li_w/3)+50,-1)}}" src="../i/loading_b.png" />
					{{? it[i].list[i_s].quanji == 1 }}
					<span class="a1">{{= it[i].list[i_s].url_len }}集全</span>
					{{?? it[i].list[i_s].quanji == 2 }}
					<span class="a1">更新至{{= it[i].list[i_s].url_len }}集</span>
					{{?? it[i].list[i_s].type == 1}}
					<span class="a1">电影</span>
					{{?}}
				</div>
				<div class="content">
					<div class="title aui-ellipsis-1">{{= it[i].list[i_s].title }}</div>
					<!--<div class="text aui-ellipsis-1">{{= it[i].list[i_s].title_text ? it[i].list[i_s].title_text : it[i].list[i_s].content }}</div>-->
				</div>
			</div>
			{{ } }}
		</div>
	</div>
	{{ } }}
	</script>
</body>
<script type="text/javascript" src="../j/api.js"></script>
<script type="text/javascript">
	var UIScrollPicture,slide_data=[],slide_is=false,slide_h;
	var li_w = $('#sx-view').width();
//	$('.img').css('height',(li_w/3)+50+'px');
	apiready = function() {
		urls();
		slide_h = $('.f-slide').height();
		UIScrollPicture = api.require('UIScrollPicture');
		shuaxin();
		_shangla(function(){
			shuaxin();
		},1)
	};
	function shuaxin(){
		slide_ajax();
		data();
	}
	function data(){
		_ajax('fang/index',function(ret,err){
			if(ret){
				var evalData = doT.template($api.html($api.byId('sx-list')));
				$api.html($api.byId('sx-view'), evalData(ret));
				_imageCache();
				api.parseTapmode();
				api.refreshHeaderLoadDone();
			}else{
				_alert(JSON.stringify(err))
			}
		})
	}
	function slide_ajax(){
		_ajax('fang/slide',function(ret,err){
			if(ret && ret.length){
				slide_data = ret;
				var slide_paths = [];
				for (var i = 0; i < ret.length; i++) {
					slide_paths.push(_img(ret[i].img,api.winWidth, slide_h));
				}
				if(slide_is){
					slide_reloadData(slide_paths)
				}else{
					setTimeout(function(){
						slide_open(slide_paths);
					},100)
				}
			}else{
				_alert(JSON.stringify(err))
			}
		})
	}
	function slide_open(paths) {
		console.log(paths)
		slide_is = true;
		UIScrollPicture.open({
			rect: {
				x: 0,
				y: 0,
				w: api.winWidth,
				h: slide_h
			},
			data: {
				paths: paths
			},
			styles: {
				indicator: {
					align: 'center',
					color: 'rgba(222, 222, 222, 0.6)',
					activeColor: '#fff',
					bottom:api.systemType == 'ios' ?5:20
				}
			},
			placeholderImg: _i+'loading_a.png',
			contentMode: 'ScaleAspectFill',
			interval: 5,
			touchWait:true,
			fixedOn: api.frameName,
			loop: true,
			fixed: false
		}, function(ret, err) {
			// console.log(JSON.stringify(ret))
			if (ret.eventType == 'click') {
				console.log(slide_data[ret.index].url)
				return eval('(' + slide_data[ret.index].url + ')');;
			}
		});
	}
	function slide_reloadData(paths){
		UIScrollPicture.reloadData({
		    data: {
		        paths: paths
		    }
		});
	}
</script>

</html>
